package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.object.pojo.OssConfig;
import com.tbit.uqbike.service.business.OssConfigService;
import com.tbit.uqbike.webmanager.dao.core.OssConfigDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: chen
 * @Description: 阿里云oss配置
 * @Date: 创建于 15:11 2020/8/3
 */
@Service
public class OssConfigServiceImpl implements OssConfigService {
    @Autowired
    private OssConfigDao ossConfigDao;

    @Override
    public OssConfig getByAccountId(Integer accountId) {
        return ossConfigDao.getByAccountId(accountId);
    }

    @Override
    public void insert(OssConfig ossConfig) {
        OssConfig ossConfigDB = getByAccountId(ossConfig.getAccountId());
        if (ossConfigDB != null) {
            edit(ossConfig);
            //修改后不需重复insert
            return;
        }
        ossConfigDao.insert(ossConfig);
    }

    @Override
    public void edit(OssConfig ossConfig) {
        ossConfigDao.edit(ossConfig);
    }
}
